import os,glob
from distutils.core import setup, Extension
from numpy.distutils.misc_util import get_numpy_include_dirs

os.system("cd ocrofstll && scons")

baselibs = ['png','m']

include_dirs = ['/usr/local/include'] + get_numpy_include_dirs()
swig_opts = ["-c++"] + ["-I" + d for d in include_dirs]
swiglib = os.popen("swig -swiglib").read()[:-1]

scripts = ["ocrofst-search","ocropus-lalign","ocropus-lmodel"]
scripts += glob.glob("ocropus-lm-*[a-z]")

ocrofstll = Extension('_ocrofstll',
        libraries = ['iulib','ocrofst']+baselibs,
        swig_opts = swig_opts,
        include_dirs = include_dirs,
        extra_link_args = ["-L.","-Locrofstll/."],
        sources = ['ocrofstll/ocrofstll.i'])

setup(name = 'ocrofst',
      version = '0.4',
      author      = "Thomas Breuel",
      description = """language modeling tools for OCRopus""",
      scripts = scripts,
      packages = ["ocrofst","ocrofstll"],
      ext_modules = [ocrofstll],
      )
